package Objects;

import java.util.ArrayList;

public class Path {
	String source;
	String destination;
	int hopCount;
	ArrayList<String> path;
	
	public Path(){
		path = new ArrayList<String>();
	}
	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}
	public String getDestination() {
		return destination;
	}
	public void setDestination(String destination) {
		this.destination = destination;
	}
	public int getHopCount(){
		return hopCount;
	}
	public void setHopCount(int hopCount){
		this.hopCount = hopCount;
	}
	public ArrayList<String> getPath() {
		return path;
	}
	public void setPath(ArrayList<String> path) {
		this.path = path;
	}
	public boolean contains(String hop){
		if(path.contains(hop))
			return true;
		else
			return false;
	}
	public String getNextHop(){
		return path.get(1);
	}
	
	@Override
	public boolean equals(Object that){
		Path thatPath = (Path)that;
		if(thatPath.getPath().size() != path.size()){
			return false;
		}
		for(int i = 0; i < thatPath.getPath().size(); i++){
			if(!thatPath.getPath().get(i).equals(path.get(i))){
				return false;
			}
		}
		return true;
	}
	
	@Override
	public String toString() {
		return "Path [source=" + source + ", destination=" + destination + ", hopCount=" + hopCount
				+ ", path=" + path + "]";
	}
	
	public String printPath() {
		String returnPath = "";
		for(int i = 0; i < path.size(); i++){
			returnPath += path.get(i) + ", ";
		}
		returnPath = returnPath.substring(0, returnPath.length()-2);
		return returnPath;
	}
}
